<?php
/**
 * Created by PhpStorm.
 * User: apple
 * Date: 2020/10/12
 * Time: 4:06 PM
 */
namespace app\admin\logic;


use app\model\SignIn;
use app\model\UserSign;
use think\facade\Request;

class SignLogic
{
    public function getList()
    {
        $param = Request::get();

        $where = [];
        if(isset($param['pername']) || !empty($param['pername'])){
            $where[] = ['pername','like','%'.trim($param['pername']).'%'];
        }

        if(isset($param['startTime']) && !empty($param['startTime'])){

            $where[] = ['sign_time','>=',strtotime(date('Y-m-d',$param['startTime']))];
        }
        if(isset($param['endTime']) && !empty($param['endTime'])){

            $where[] = ['sign_time','<=',strtotime(date('Y-m-d 23:59:59',$param['endTime']))];
        }

        $where[] = ['sign_status','=',1];    //默认是 没删除的
        $where[] = ['sign_orgid','=',config('user')['orgid']];
        $signModel = new SignIn();
        $list = $signModel->getSignPageListByWhere($where);
        return $list;
    }

    public function download()
    {
        $param = Request::get();

        $where = [];
        if(isset($param['pername']) || !empty($param['pername'])){
            $where[] = ['pername','like','%'.trim($param['pername']).'%'];
        }

        if(isset($param['startTime']) && !empty($param['startTime'])){

            $where[] = ['sign_time','>=',strtotime(date('Y-m-d',$param['startTime']))];
        }
        if(isset($param['endTime']) && !empty($param['endTime'])){

            $where[] = ['sign_time','<=',strtotime(date('Y-m-d 23:59:59',$param['endTime']))];
        }
        $where[] = ['sign_status','=',1];    //默认是 没删除的
        $where[] = ['sign_orgid','=',config('user')['orgid']];
        $signModel = new SignIn();
        $list = $signModel->getSignListByWhere($where);
        return $list;
    }

    public function getSignList()
    {
        $param = Request::get();

        $where = [];
        if(isset($param['pername']) || !empty($param['pername'])){
            $where[] = ['pername','like','%'.trim($param['pername']).'%'];
        }

        if(isset($param['startTime']) && !empty($param['startTime'])){
            $where[] = ['us_start_time','>=',strtotime(date('Y-m-d',$param['startTime']))];
        }
        if(isset($param['endTime']) && !empty($param['endTime'])){
            $where[] = ['us_start_time','<=',strtotime(date('Y-m-d 23:59:59',$param['endTime']))];
        }

        $where[] = ['us_status','=',1];    //默认是 没删除的
        $where[] = ['us_orgid','=',config('user')['orgid']];
        $signModel = new UserSign();
        $list = $signModel->getSignPageListByWhere($where);
        return $list;
    }

    public function downloadSignList()
    {
        $param = Request::get();

        $where = [];
        if(isset($param['pername']) || !empty($param['pername'])){
            $where[] = ['pername','like','%'.trim($param['pername']).'%'];
        }

        if(isset($param['startTime']) && !empty($param['startTime'])){

            $where[] = ['sign_time','>=',strtotime(date('Y-m-d',$param['startTime']))];
        }
        if(isset($param['endTime']) && !empty($param['endTime'])){

            $where[] = ['sign_time','<=',strtotime(date('Y-m-d 23:59:59',$param['endTime']))];
        }
        $where[] = ['sign_status','=',1];    //默认是 没删除的
        $where[] = ['sign_orgid','=',config('user')['orgid']];
        $signModel = new SignIn();
        $list = $signModel->getSignListByWhere($where);
        return $list;
    }

}